package com.dhc.redpacket.service.Imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhc.redpacket.dao.RedPacketDao;
import com.dhc.redpacket.pojo.RedPacket;
import com.dhc.redpacket.service.RedPacketService;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class RedPacketServiceImp implements RedPacketService {

  @Autowired
  private RedPacketDao redPacketDao = null;

  @Override
  @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
  public RedPacket getRedPacket(Long id) throws Exception {
    return redPacketDao.getRedPacket(id);
  }

  @Override
  @Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
  public int decreaseRedPacket(Long id) throws Exception {
    return redPacketDao.decreaseRedPacket(id);
  }
}
